<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>lwIP: src/include/lwip/mem.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">lwIP
   &#160;<span id="projectnumber">2.1.2</span>
   </div>
   <div id="projectbrief">Lightweight IP stack</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('mem_8h.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">mem.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="opt_8h.html">lwip/opt.h</a>&quot;</code><br />
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a44a136e3b70c36abb6f8dc060c778113"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mem_8h.html#a44a136e3b70c36abb6f8dc060c778113">mem_init</a> (void)</td></tr>
<tr class="separator:a44a136e3b70c36abb6f8dc060c778113"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5e39a108c44d8a72df0b30a117cb62e4"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mem_8h.html#a5e39a108c44d8a72df0b30a117cb62e4">mem_trim</a> (void *<a class="el" href="structmem.html">mem</a>, mem_size_t size)</td></tr>
<tr class="separator:a5e39a108c44d8a72df0b30a117cb62e4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a932aa40d85b14cb7331625e012d12335"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mem_8h.html#a932aa40d85b14cb7331625e012d12335">mem_malloc</a> (mem_size_t size)</td></tr>
<tr class="separator:a932aa40d85b14cb7331625e012d12335"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab0bdc525971701883f2065e7fb257a24"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mem_8h.html#ab0bdc525971701883f2065e7fb257a24">mem_calloc</a> (mem_size_t count, mem_size_t size)</td></tr>
<tr class="separator:ab0bdc525971701883f2065e7fb257a24"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2fd7aa1adf6e394d3be7c7734e7df41a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mem_8h.html#a2fd7aa1adf6e394d3be7c7734e7df41a">mem_free</a> (void *<a class="el" href="structmem.html">mem</a>)</td></tr>
<tr class="separator:a2fd7aa1adf6e394d3be7c7734e7df41a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Heap API </p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="ab0bdc525971701883f2065e7fb257a24"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab0bdc525971701883f2065e7fb257a24">&#9670;&nbsp;</a></span>mem_calloc()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* mem_calloc </td>
          <td>(</td>
          <td class="paramtype">mem_size_t&#160;</td>
          <td class="paramname"><em>count</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">mem_size_t&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Contiguously allocates enough space for count objects that are size bytes of memory each and returns a pointer to the allocated memory.</p>
<p>The allocated memory is filled with bytes of value zero.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">count</td><td>number of objects to allocate </td></tr>
    <tr><td class="paramname">size</td><td>size of the objects to allocate </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>pointer to allocated memory / NULL pointer if there is an error </dd></dl>

</div>
</div>
<a id="a2fd7aa1adf6e394d3be7c7734e7df41a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2fd7aa1adf6e394d3be7c7734e7df41a">&#9670;&nbsp;</a></span>mem_free()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mem_free </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>rmem</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Put a struct mem back on the heap</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">rmem</td><td>is the data portion of a struct mem as returned by a previous call to <a class="el" href="mem_8c.html#af418ade27d91d41e6143dba2cc246b0f">mem_malloc()</a> </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a44a136e3b70c36abb6f8dc060c778113"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a44a136e3b70c36abb6f8dc060c778113">&#9670;&nbsp;</a></span>mem_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mem_init </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Zero the heap and initialize start, end and lowest-free </p>

</div>
</div>
<a id="a932aa40d85b14cb7331625e012d12335"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a932aa40d85b14cb7331625e012d12335">&#9670;&nbsp;</a></span>mem_malloc()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* mem_malloc </td>
          <td>(</td>
          <td class="paramtype">mem_size_t&#160;</td>
          <td class="paramname"><em>size_in</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Allocate a block of memory with a minimum of 'size' bytes.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">size_in</td><td>is the minimum size of the requested block in bytes. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>pointer to allocated memory or NULL if no free memory was found.</dd></dl>
<p>Note that the returned value will always be aligned (as defined by MEM_ALIGNMENT). </p>

</div>
</div>
<a id="a5e39a108c44d8a72df0b30a117cb62e4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5e39a108c44d8a72df0b30a117cb62e4">&#9670;&nbsp;</a></span>mem_trim()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* mem_trim </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>rmem</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">mem_size_t&#160;</td>
          <td class="paramname"><em>new_size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Shrink memory returned by <a class="el" href="mem_8c.html#af418ade27d91d41e6143dba2cc246b0f">mem_malloc()</a>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">rmem</td><td>pointer to memory allocated by mem_malloc the is to be shrinked </td></tr>
    <tr><td class="paramname">new_size</td><td>required size after shrinking (needs to be smaller than or equal to the previous size) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>for compatibility reasons: is always == rmem, at the moment or NULL if newsize is &gt; old size, in which case rmem is NOT touched or freed! </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_b0856f6b0d80ccb263b2f415c91f9e17.html">include</a></li><li class="navelem"><a class="el" href="dir_4e6b3cf33a61b6caac9c8ac30c866f37.html">lwip</a></li><li class="navelem"><a class="el" href="mem_8h.html">mem.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
